package com.menu.Controller;

import com.menu.Pojo.SecurityUser;
import com.menu.Service.NoticeService;
import com.menu.Utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Api(tags = "通知接口")
public class NoticeController {
    @Resource
    NoticeService noticeService;


    @ApiOperation(value = "批量删除通知")
    @DeleteMapping("/User/batchDeleteNotice")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "noticeId", value = "通知id", required = true, allowMultiple = true,dataTypeClass = List.class)
            }
    )
    public ResponseResult batchDeleteNotice(Integer[] noticeId){
        return noticeService.batchDeleteNotice(noticeId);
    }

    @ApiOperation(value = "单个删除通知")
    @DeleteMapping("/User/deleteNotice")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "noticeId", value = "通知id", required = true)
            }
    )
    public ResponseResult deleteNotice(Integer noticeId){
        return noticeService.deleteNotice(noticeId);
    }

    @ApiOperation(value = "遍历某用户收藏食谱,收藏菜单,点赞食谱的通知")
    @GetMapping("/User/findCollectionAndThumbsUpNotice")
    public ResponseResult findCollectionAndThumbsUpNotice(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser,Integer pageNow,Integer pageSize){
        return noticeService.findCollectionAndThumbsUpNotice(securityUser.getUserId(),pageNow,pageSize);
    }


    @ApiOperation(value = "遍历某用户被关注的通知")
    @GetMapping("/User/findAttentionNotice")
    public ResponseResult findAttentionNotice(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser,Integer pageNow,Integer pageSize){
        return noticeService.findAttentionNotice(securityUser.getUserId(),pageNow,pageSize);
    }


    @ApiOperation(value = "遍历某用户官方的通知")
    @GetMapping("/User/findOfficialNoticeByUserIdOrderByNoticeTime")
    public ResponseResult findOfficialNoticeByUserIdOrderByNoticeTime(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser,Integer pageNow,Integer pageSize){
        return noticeService.findOfficialNoticeByUserIdOrderByNoticeTime(securityUser.getUserId(),pageNow,pageSize);
    }


}
